import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class TestNormalize {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		for (int i=0;i<args.length;i++){

			BufferedReader br;
			try {
				br = new BufferedReader(new FileReader(args[i]));

				String str = br.readLine();
				StringBuilder sb = new StringBuilder();
				while (str!=null){
					sb.append(str + "\r\n");
					str=br.readLine();
				}
				str = sb.toString();
				ScriptNode sn = new ScriptNode(str);
				Normalizer norm = new Normalizer(sn);
				str = norm.Normalize().getNormCode();
				File f = new File("nor_"+args[i]);
				BufferedWriter bw = new BufferedWriter(new FileWriter(f));
				bw.write(str);
				bw.close();
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (DetectorException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}

}
